USE [ERP]
GO

/****** Object:  StoredProcedure [dbo].[SP_USERS_INSERT_UPDATE]    Script Date: 11/22/2009 15:15:04 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[SP_USERS_INSERT_UPDATE]
	-- Add the parameters for the stored procedure here
	@username nvarchar(50),
	@password nvarchar(50),
	@status int,
	@id nvarchar(50),
	@employeeId nvarchar(50)
AS
BEGIN
	UPDATE Users 
		SET Username = @username,
		Password = @password ,
		Status = @status ,
		EmployeeID = @employeeId 
	WHERE ID = @ID	
	
	IF @@ROWCOUNT = 0 
	BEGIN
		INSERT INTO Users (ID, EmployeeID, Username, Password, Status)
		VALUES (@id, @employeeId, @username, @password, @status )
	END
	
	RETURN @@ROWCOUNT
END

GO

